package com.xianggu.designMode.combination.demo03;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author chengjy
 * @date 2025/3/20
 */
public class Province implements PopulationNode{

    private String name;
    private List<PopulationNode> citys = new ArrayList<>();

    public Province(String name) {
        this.name = name;
    }

    @Override
    public int counPopulation() {
        return citys.stream().mapToInt(PopulationNode::counPopulation).sum();
    }

    @Override
    public String getName() {
        return this.name;
    }

    public void addCity(City city){
        this.citys.add(city);
    }
    public void addCitys(City... city){
        this.citys.addAll(Arrays.asList( city));
    }
}
